﻿@model DAEProde.Tasks.ViewModels.EditMatchViewModel

@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Editar Partido</h2>

@using (Html.BeginForm("Edit", "MatchManager"))
{
    @Html.ValidationSummary("Please note the following:")
    @Html.AntiForgeryToken()

    <fieldset>
        <legend>Datos</legend>

        @Html.HiddenFor(m => m.Match.Id)

        <div class="editor-label">
            @Html.LabelFor(m => m.Match.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(m => m.Match.Name)
            @Html.ValidationMessageFor(m => m.Match.Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(m => m.Match.Date)
        </div>
        <div class="editor-field">
            @Html.EditorFor(m => m.Match.Date)
            @Html.ValidationMessageFor(m => m.Match.Date)
        </div>        

        <div class="editor-label">
            @Html.LabelFor(m => m.Match.MatchDate)
        </div>
        <div class="editor-field">
            <!-- Manually creating dropdown because ASP.NET MVC won't handle selected-value correctly, IMO -->
            <!-- This would be a good item for a helper, which is beyond the scope of this sample. -->
            <select name="Match.MatchDate">
                <option value="0">-- Seleccione Fecha --</option>
                @foreach (var matchDate in Model.AvaileableMatchDates) {
                    <option value="@matchDate.Id" @(matchDate.Equals(Model.Match.MatchDate) ? "selected=\"selected\"" : "")>@matchDate.Name - @matchDate.Date.ToShortDateString()</option>
                }
            </select>
            @Html.ValidationMessageFor(m => m.Match.MatchDate)
        </div>

        <div class="editor-label">
            @Html.LabelFor(m => m.Match.LocalTeam)
        </div>
        <div class="editor-field">
            <!-- Manually creating dropdown because ASP.NET MVC won't handle selected-value correctly, IMO -->
            <!-- This would be a good item for a helper, which is beyond the scope of this sample. -->
            <select name="Match.LocalTeam">
                <option value="0">-- Seleccione Equipo --</option>
                @foreach (var team in Model.AvaileableTeams) {
                    <option value="@team.Id" @(team.Equals(Model.Match.LocalTeam) ? "selected=\"selected\"" : "")>@team.Name</option>
                }
            </select>
            @Html.ValidationMessageFor(m => m.Match.LocalTeam)
        </div>

        <div class="editor-label">
            @Html.LabelFor(m => m.Match.OutTeam)
        </div>
        <div class="editor-field">
            <!-- Manually creating dropdown because ASP.NET MVC won't handle selected-value correctly, IMO -->
            <!-- This would be a good item for a helper, which is beyond the scope of this sample. -->
            <select name="Match.OutTeam">
                <option value="0">-- Seleccione Equipo --</option>
                @foreach (var team in Model.AvaileableTeams) {
                    <option value="@team.Id" @(team.Equals(Model.Match.OutTeam) ? "selected=\"selected\"" : "")>@team.Name</option>
                }
            </select>
            @Html.ValidationMessageFor(m => m.Match.OutTeam)
        </div>

        <p>
            <input type="submit" value="Guardar" /> 
            @Html.ActionLink("Cancelar", "Index", new { id = Model.Match.MatchDate.Id })
        </p>
    </fieldset>
}